1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.Entry; 26 27 private import gdk.ContentProvider; 28 private import gdk.PaintableIF; 29 private import gio.IconIF; 30 private import gio.MenuModel; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import glib.c.functions; 34 private import gobject.ObjectG; 35 private import gobject.Signals; 36 private import gtk.CellEditableIF; 37 private import gtk.CellEditableT; 38 private import gtk.EditableIF; 39 private import gtk.EditableT; 40 private import gtk.EntryBuffer; 41 private import gtk.EntryCompletion; 42 private import gtk.Widget; 43 private import gtk.c.functions; 44 public import gtk.c.types; 45 private import pango.PgAttributeList; 46 private import pango.PgTabArray; 47 private import std.algorithm; 48 49 50 /** 51 * `GtkEntry` is a single line text entry widget. 52 * 53 *  54 * 55 * A fairly large set of key bindings are supported by default. If the 56 * entered text is longer than the allocation of the widget, the widget 57 * will scroll so that the cursor position is visible. 58 * 59 * When using an entry for passwords and other sensitive information, it 60 * can be put into “password mode” using [method@Gtk.Entry.set_visibility]. 61 * In this mode, entered text is displayed using a “invisible” character. 62 * By default, GTK picks the best invisible character that is available 63 * in the current font, but it can be changed with 64 * [method@Gtk.Entry.set_invisible_char]. 65 * 66 * `GtkEntry` has the ability to display progress or activity 67 * information behind the text. To make an entry display such information, 68 * use [method@Gtk.Entry.set_progress_fraction] or 69 * [method@Gtk.Entry.set_progress_pulse_step]. 70 * 71 * Additionally, `GtkEntry` can show icons at either side of the entry. 72 * These icons can be activatable by clicking, can be set up as drag source 73 * and can have tooltips. To add an icon, use 74 * [method@Gtk.Entry.set_icon_from_gicon] or one of the various other functions 75 * that set an icon from an icon name or a paintable. To trigger an action when 76 * the user clicks an icon, connect to the [signal@Gtk.Entry::icon-press] signal. 77 * To allow DND operations from an icon, use 78 * [method@Gtk.Entry.set_icon_drag_source]. To set a tooltip on an icon, use 79 * [method@Gtk.Entry.set_icon_tooltip_text] or the corresponding function 80 * for markup. 81 * 82 * Note that functionality or information that is only available by clicking 83 * on an icon in an entry may not be accessible at all to users which are not 84 * able to use a mouse or other pointing device. It is therefore recommended 85 * that any such functionality should also be available by other means, e.g. 86 * via the context menu of the entry. 87 * 88 * # CSS nodes 89 * 90 * ``` 91 * entry[.flat][.warning][.error] 92 * ├── text[.readonly] 93 * ├── image.left 94 * ├── image.right 95 * ╰── [progress[.pulse]] 96 * ``` 97 * 98 * `GtkEntry` has a main node with the name entry. Depending on the properties 99 * of the entry, the style classes .read-only and .flat may appear. The style 100 * classes .warning and .error may also be used with entries. 101 * 102 * When the entry shows icons, it adds subnodes with the name image and the 103 * style class .left or .right, depending on where the icon appears. 104 * 105 * When the entry shows progress, it adds a subnode with the name progress. 106 * The node has the style class .pulse when the shown progress is pulsing. 107 * 108 * For all the subnodes added to the text node in various situations, 109 * see [class@Gtk.Text]. 110 * 111 * # GtkEntry as GtkBuildable 112 * 113 * The `GtkEntry` implementation of the `GtkBuildable` interface supports a 114 * custom <attributes> element, which supports any number of <attribute> 115 * elements. The <attribute> element has attributes named “name“, “value“, 116 * “start“ and “end“ and allows you to specify `PangoAttribute` values for 117 * this label. 118 * 119 * An example of a UI definition fragment specifying Pango attributes: 120 * ```xml 121 * <object class="GtkEntry"> 122 * <attributes> 123 * <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> 124 * <attribute name="background" value="red" start="5" end="10"/> 125 * </attributes> 126 * </object> 127 * ``` 128 * 129 * The start and end attributes specify the range of characters to which the 130 * Pango attribute applies. If start and end are not specified, the attribute 131 * is applied to the whole text. Note that specifying ranges does not make much 132 * sense with translatable attributes. Use markup embedded in the translatable 133 * content instead. 134 * 135 * # Accessibility 136 * 137 * `GtkEntry` uses the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role. 138 */ 139 public class Entry : Widget, CellEditableIF, EditableIF 140 { 141 /** the main Gtk struct */ 142 protected GtkEntry* gtkEntry; 143 144 /** Get the main Gtk struct */ 145 public GtkEntry* getEntryStruct(bool transferOwnership = false) 146 { 147 if (transferOwnership) 148 ownedRef = false; 149 return gtkEntry; 150 } 151 152 /** the main Gtk struct as a void* */ 153 protected override void* getStruct() 154 { 155 return cast(void*)gtkEntry; 156 } 157 158 /** 159 * Sets our main struct and passes it to the parent class. 160 */ 161 public this (GtkEntry* gtkEntry, bool ownedRef = false) 162 { 163 this.gtkEntry = gtkEntry; 164 super(cast(GtkWidget*)gtkEntry, ownedRef); 165 } 166 167 // add the CellEditable capabilities 168 mixin CellEditableT!(GtkEntry); 169 170 // add the Editable capabilities 171 mixin EditableT!(GtkEntry); 172 173 174 /** */ 175 public static GType getType() 176 { 177 return gtk_entry_get_type(); 178 } 179 180 /** 181 * Creates a new entry. 182 * 183 * Returns: a new `GtkEntry`. 184 * 185 * Throws: ConstructionException GTK+ fails to create the object. 186 */ 187 public this() 188 { 189 auto __p = gtk_entry_new(); 190 191 if(__p is null) 192 { 193 throw new ConstructionException("null returned by new"); 194 } 195 196 this(cast(GtkEntry*) __p); 197 } 198 199 /** 200 * Creates a new entry with the specified text buffer. 201 * 202 * Params: 203 * buffer = The buffer to use for the new `GtkEntry`. 204 * 205 * Returns: a new `GtkEntry` 206 * 207 * Throws: ConstructionException GTK+ fails to create the object. 208 */ 209 public this(EntryBuffer buffer) 210 { 211 auto __p = gtk_entry_new_with_buffer((buffer is null) ? null : buffer.getEntryBufferStruct()); 212 213 if(__p is null) 214 { 215 throw new ConstructionException("null returned by new_with_buffer"); 216 } 217 218 this(cast(GtkEntry*) __p); 219 } 220 221 /** 222 * Retrieves the value set by gtk_entry_set_activates_default(). 223 * 224 * Returns: %TRUE if the entry will activate the default widget 225 */ 226 public bool getActivatesDefault() 227 { 228 return gtk_entry_get_activates_default(gtkEntry) != 0; 229 } 230 231 /** 232 * Gets the value set by gtk_entry_set_alignment(). 233 * 234 * See also: [property@Gtk.Editable:xalign] 235 * 236 * Returns: the alignment 237 */ 238 public float getAlignment() 239 { 240 return gtk_entry_get_alignment(gtkEntry); 241 } 242 243 /** 244 * Gets the attribute list of the `GtkEntry`. 245 * 246 * See [method@Gtk.Entry.set_attributes]. 247 * 248 * Returns: the attribute list 249 */ 250 public PgAttributeList getAttributes() 251 { 252 auto __p = gtk_entry_get_attributes(gtkEntry); 253 254 if(__p is null) 255 { 256 return null; 257 } 258 259 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) __p); 260 } 261 262 /** 263 * Get the `GtkEntryBuffer` object which holds the text for 264 * this widget. 265 * 266 * Returns: A `GtkEntryBuffer` object. 267 */ 268 public EntryBuffer getBuffer() 269 { 270 auto __p = gtk_entry_get_buffer(gtkEntry); 271 272 if(__p is null) 273 { 274 return null; 275 } 276 277 return ObjectG.getDObject!(EntryBuffer)(cast(GtkEntryBuffer*) __p); 278 } 279 280 /** 281 * Returns the auxiliary completion object currently 282 * in use by @entry. 283 * 284 * Returns: The auxiliary 285 * completion object currently in use by @entry 286 */ 287 public EntryCompletion getCompletion() 288 { 289 auto __p = gtk_entry_get_completion(gtkEntry); 290 291 if(__p is null) 292 { 293 return null; 294 } 295 296 return ObjectG.getDObject!(EntryCompletion)(cast(GtkEntryCompletion*) __p); 297 } 298 299 /** 300 * Returns the index of the icon which is the source of the 301 * current DND operation, or -1. 302 * 303 * Returns: index of the icon which is the source of the 304 * current DND operation, or -1. 305 */ 306 public int getCurrentIconDragSource() 307 { 308 return gtk_entry_get_current_icon_drag_source(gtkEntry); 309 } 310 311 /** 312 * Gets the menu model set with gtk_entry_set_extra_menu(). 313 * 314 * Returns: the menu model 315 */ 316 public MenuModel getExtraMenu() 317 { 318 auto __p = gtk_entry_get_extra_menu(gtkEntry); 319 320 if(__p is null) 321 { 322 return null; 323 } 324 325 return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p); 326 } 327 328 /** 329 * Gets the value set by gtk_entry_set_has_frame(). 330 * 331 * Returns: whether the entry has a beveled frame 332 */ 333 public bool getHasFrame() 334 { 335 return gtk_entry_get_has_frame(gtkEntry) != 0; 336 } 337 338 /** 339 * Returns whether the icon is activatable. 340 * 341 * Params: 342 * iconPos = Icon position 343 * 344 * Returns: %TRUE if the icon is activatable. 345 */ 346 public bool getIconActivatable(GtkEntryIconPosition iconPos) 347 { 348 return gtk_entry_get_icon_activatable(gtkEntry, iconPos) != 0; 349 } 350 351 /** 352 * Gets the area where entry’s icon at @icon_pos is drawn. 353 * 354 * This function is useful when drawing something to the 355 * entry in a draw callback. 356 * 357 * If the entry is not realized or has no icon at the given 358 * position, @icon_area is filled with zeros. Otherwise, 359 * @icon_area will be filled with the icon's allocation, 360 * relative to @entry's allocation. 361 * 362 * Params: 363 * iconPos = Icon position 364 * iconArea = Return location for the icon’s area 365 */ 366 public void getIconArea(GtkEntryIconPosition iconPos, out GdkRectangle iconArea) 367 { 368 gtk_entry_get_icon_area(gtkEntry, iconPos, &iconArea); 369 } 370 371 /** 372 * Finds the icon at the given position and return its index. 373 * 374 * The position’s coordinates are relative to the @entry’s 375 * top left corner. If @x, @y doesn’t lie inside an icon, 376 * -1 is returned. This function is intended for use in a 377 * [signal@Gtk.Widget::query-tooltip] signal handler. 378 * 379 * Params: 380 * x = the x coordinate of the position to find, relative to @entry 381 * y = the y coordinate of the position to find, relative to @entry 382 * 383 * Returns: the index of the icon at the given position, or -1 384 */ 385 public int getIconAtPos(int x, int y) 386 { 387 return gtk_entry_get_icon_at_pos(gtkEntry, x, y); 388 } 389 390 /** 391 * Retrieves the `GIcon` used for the icon. 392 * 393 * %NULL will be returned if there is no icon or if the icon was 394 * set by some other method (e.g., by `GdkPaintable` or icon name). 395 * 396 * Params: 397 * iconPos = Icon position 398 * 399 * Returns: A `GIcon` 400 */ 401 public IconIF getIconGicon(GtkEntryIconPosition iconPos) 402 { 403 auto __p = gtk_entry_get_icon_gicon(gtkEntry, iconPos); 404 405 if(__p is null) 406 { 407 return null; 408 } 409 410 return ObjectG.getDObject!(IconIF)(cast(GIcon*) __p); 411 } 412 413 /** 414 * Retrieves the icon name used for the icon. 415 * 416 * %NULL is returned if there is no icon or if the icon was set 417 * by some other method (e.g., by `GdkPaintable` or gicon). 418 * 419 * Params: 420 * iconPos = Icon position 421 * 422 * Returns: An icon name 423 */ 424 public string getIconName(GtkEntryIconPosition iconPos) 425 { 426 return Str.toString(gtk_entry_get_icon_name(gtkEntry, iconPos)); 427 } 428 429 /** 430 * Retrieves the `GdkPaintable` used for the icon. 431 * 432 * If no `GdkPaintable` was used for the icon, %NULL is returned. 433 * 434 * Params: 435 * iconPos = Icon position 436 * 437 * Returns: A `GdkPaintable` 438 * if no icon is set for this position or the icon set is not 439 * a `GdkPaintable`. 440 */ 441 public PaintableIF getIconPaintable(GtkEntryIconPosition iconPos) 442 { 443 auto __p = gtk_entry_get_icon_paintable(gtkEntry, iconPos); 444 445 if(__p is null) 446 { 447 return null; 448 } 449 450 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p); 451 } 452 453 /** 454 * Returns whether the icon appears sensitive or insensitive. 455 * 456 * Params: 457 * iconPos = Icon position 458 * 459 * Returns: %TRUE if the icon is sensitive. 460 */ 461 public bool getIconSensitive(GtkEntryIconPosition iconPos) 462 { 463 return gtk_entry_get_icon_sensitive(gtkEntry, iconPos) != 0; 464 } 465 466 /** 467 * Gets the type of representation being used by the icon 468 * to store image data. 469 * 470 * If the icon has no image data, the return value will 471 * be %GTK_IMAGE_EMPTY. 472 * 473 * Params: 474 * iconPos = Icon position 475 * 476 * Returns: image representation being used 477 */ 478 public GtkImageType getIconStorageType(GtkEntryIconPosition iconPos) 479 { 480 return gtk_entry_get_icon_storage_type(gtkEntry, iconPos); 481 } 482 483 /** 484 * Gets the contents of the tooltip on the icon at the specified 485 * position in @entry. 486 * 487 * Params: 488 * iconPos = the icon position 489 * 490 * Returns: the tooltip text 491 */ 492 public string getIconTooltipMarkup(GtkEntryIconPosition iconPos) 493 { 494 auto retStr = gtk_entry_get_icon_tooltip_markup(gtkEntry, iconPos); 495 496 scope(exit) Str.freeString(retStr); 497 return Str.toString(retStr); 498 } 499 500 /** 501 * Gets the contents of the tooltip on the icon at the specified 502 * position in @entry. 503 * 504 * Params: 505 * iconPos = the icon position 506 * 507 * Returns: the tooltip text 508 */ 509 public string getIconTooltipText(GtkEntryIconPosition iconPos) 510 { 511 auto retStr = gtk_entry_get_icon_tooltip_text(gtkEntry, iconPos); 512 513 scope(exit) Str.freeString(retStr); 514 return Str.toString(retStr); 515 } 516 517 /** 518 * Gets the input hints of this `GtkEntry`. 519 * 520 * Returns: the input hints 521 */ 522 public GtkInputHints getInputHints() 523 { 524 return gtk_entry_get_input_hints(gtkEntry); 525 } 526 527 /** 528 * Gets the input purpose of the `GtkEntry`. 529 * 530 * Returns: the input purpose 531 */ 532 public GtkInputPurpose getInputPurpose() 533 { 534 return gtk_entry_get_input_purpose(gtkEntry); 535 } 536 537 /** 538 * Retrieves the character displayed in place of the actual text 539 * in “password mode”. 540 * 541 * Returns: the current invisible char, or 0, if the entry does not 542 * show invisible text at all. 543 */ 544 public dchar getInvisibleChar() 545 { 546 return gtk_entry_get_invisible_char(gtkEntry); 547 } 548 549 /** 550 * Retrieves the maximum allowed length of the text in @entry. 551 * 552 * See [method@Gtk.Entry.set_max_length]. 553 * 554 * Returns: the maximum allowed number of characters 555 * in `GtkEntry`, or 0 if there is no maximum. 556 */ 557 public int getMaxLength() 558 { 559 return gtk_entry_get_max_length(gtkEntry); 560 } 561 562 /** 563 * Gets whether the `GtkEntry` is in overwrite mode. 564 * 565 * Returns: whether the text is overwritten when typing. 566 */ 567 public bool getOverwriteMode() 568 { 569 return gtk_entry_get_overwrite_mode(gtkEntry) != 0; 570 } 571 572 /** 573 * Retrieves the text that will be displayed when @entry 574 * is empty and unfocused 575 * 576 * Returns: a pointer to the 577 * placeholder text as a string. This string points to 578 * internally allocated storage in the widget and must 579 * not be freed, modified or stored. If no placeholder 580 * text has been set, %NULL will be returned. 581 */ 582 public string getPlaceholderText() 583 { 584 return Str.toString(gtk_entry_get_placeholder_text(gtkEntry)); 585 } 586 587 /** 588 * Returns the current fraction of the task that’s been completed. 589 * 590 * See [method@Gtk.Entry.set_progress_fraction]. 591 * 592 * Returns: a fraction from 0.0 to 1.0 593 */ 594 public double getProgressFraction() 595 { 596 return gtk_entry_get_progress_fraction(gtkEntry); 597 } 598 599 /** 600 * Retrieves the pulse step set with 601 * gtk_entry_set_progress_pulse_step(). 602 * 603 * Returns: a fraction from 0.0 to 1.0 604 */ 605 public double getProgressPulseStep() 606 { 607 return gtk_entry_get_progress_pulse_step(gtkEntry); 608 } 609 610 /** 611 * Gets the tabstops of the `GtkEntry. 612 * 613 * See [method@Gtk.Entry.set_tabs]. 614 * 615 * Returns: the tabstops 616 */ 617 public PgTabArray getTabs() 618 { 619 auto __p = gtk_entry_get_tabs(gtkEntry); 620 621 if(__p is null) 622 { 623 return null; 624 } 625 626 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) __p); 627 } 628 629 /** 630 * Retrieves the current length of the text in @entry. 631 * 632 * This is equivalent to getting @entry's `GtkEntryBuffer` 633 * and calling [method@Gtk.EntryBuffer.get_length] on it. 634 * 635 * Returns: the current number of characters 636 * in `GtkEntry`, or 0 if there are none. 637 */ 638 public ushort getTextLength() 639 { 640 return gtk_entry_get_text_length(gtkEntry); 641 } 642 643 /** 644 * Retrieves whether the text in @entry is visible. 645 * 646 * See [method@Gtk.Entry.set_visibility]. 647 * 648 * Returns: %TRUE if the text is currently visible 649 */ 650 public bool getVisibility() 651 { 652 return gtk_entry_get_visibility(gtkEntry) != 0; 653 } 654 655 /** 656 * Causes @entry to have keyboard focus. 657 * 658 * It behaves like [method@Gtk.Widget.grab_focus], except that it doesn't 659 * select the contents of the entry. You only want to call this on some 660 * special entries which the user usually doesn't want to replace all text 661 * in, such as search-as-you-type entries. 662 * 663 * Returns: %TRUE if focus is now inside @self 664 */ 665 public bool grabFocusWithoutSelecting() 666 { 667 return gtk_entry_grab_focus_without_selecting(gtkEntry) != 0; 668 } 669 670 /** 671 * Indicates that some progress is made, but you don’t 672 * know how much. 673 * 674 * Causes the entry’s progress indicator to enter “activity 675 * mode”, where a block bounces back and forth. Each call to 676 * gtk_entry_progress_pulse() causes the block to move by a 677 * little bit (the amount of movement per pulse is determined 678 * by [method@Gtk.Entry.set_progress_pulse_step]). 679 */ 680 public void progressPulse() 681 { 682 gtk_entry_progress_pulse(gtkEntry); 683 } 684 685 /** 686 * Reset the input method context of the entry if needed. 687 * 688 * This can be necessary in the case where modifying the buffer 689 * would confuse on-going input method behavior. 690 */ 691 public void resetImContext() 692 { 693 gtk_entry_reset_im_context(gtkEntry); 694 } 695 696 /** 697 * Sets whether pressing Enter in the @entry will activate the default 698 * widget for the window containing the entry. 699 * 700 * This usually means that the dialog containing the entry will be closed, 701 * since the default widget is usually one of the dialog buttons. 702 * 703 * Params: 704 * setting = %TRUE to activate window’s default widget on Enter keypress 705 */ 706 public void setActivatesDefault(bool setting) 707 { 708 gtk_entry_set_activates_default(gtkEntry, setting); 709 } 710 711 /** 712 * Sets the alignment for the contents of the entry. 713 * 714 * This controls the horizontal positioning of the contents when 715 * the displayed text is shorter than the width of the entry. 716 * 717 * See also: [property@Gtk.Editable:xalign] 718 * 719 * Params: 720 * xalign = The horizontal alignment, from 0 (left) to 1 (right). 721 * Reversed for RTL layouts 722 */ 723 public void setAlignment(float xalign) 724 { 725 gtk_entry_set_alignment(gtkEntry, xalign); 726 } 727 728 /** 729 * Sets a `PangoAttrList`. 730 * 731 * The attributes in the list are applied to the entry text. 732 * 733 * Since the attributes will be applies to text that changes 734 * as the user types, it makes most sense to use attributes 735 * with unlimited extent. 736 * 737 * Params: 738 * attrs = a `PangoAttrList` 739 */ 740 public void setAttributes(PgAttributeList attrs) 741 { 742 gtk_entry_set_attributes(gtkEntry, (attrs is null) ? null : attrs.getPgAttributeListStruct()); 743 } 744 745 /** 746 * Set the `GtkEntryBuffer` object which holds the text for 747 * this widget. 748 * 749 * Params: 750 * buffer = a `GtkEntryBuffer` 751 */ 752 public void setBuffer(EntryBuffer buffer) 753 { 754 gtk_entry_set_buffer(gtkEntry, (buffer is null) ? null : buffer.getEntryBufferStruct()); 755 } 756 757 /** 758 * Sets @completion to be the auxiliary completion object 759 * to use with @entry. 760 * 761 * All further configuration of the completion mechanism is 762 * done on @completion using the `GtkEntryCompletion` API. 763 * Completion is disabled if @completion is set to %NULL. 764 * 765 * Params: 766 * completion = The `GtkEntryCompletion` 767 */ 768 public void setCompletion(EntryCompletion completion) 769 { 770 gtk_entry_set_completion(gtkEntry, (completion is null) ? null : completion.getEntryCompletionStruct()); 771 } 772 773 /** 774 * Sets a menu model to add when constructing 775 * the context menu for @entry. 776 * 777 * Params: 778 * model = a `GMenuModel` 779 */ 780 public void setExtraMenu(MenuModel model) 781 { 782 gtk_entry_set_extra_menu(gtkEntry, (model is null) ? null : model.getMenuModelStruct()); 783 } 784 785 /** 786 * Sets whether the entry has a beveled frame around it. 787 * 788 * Params: 789 * setting = new value 790 */ 791 public void setHasFrame(bool setting) 792 { 793 gtk_entry_set_has_frame(gtkEntry, setting); 794 } 795 796 /** 797 * Sets whether the icon is activatable. 798 * 799 * Params: 800 * iconPos = Icon position 801 * activatable = %TRUE if the icon should be activatable 802 */ 803 public void setIconActivatable(GtkEntryIconPosition iconPos, bool activatable) 804 { 805 gtk_entry_set_icon_activatable(gtkEntry, iconPos, activatable); 806 } 807 808 /** 809 * Sets up the icon at the given position as drag source. 810 * 811 * This makes it so that GTK will start a drag 812 * operation when the user clicks and drags the icon. 813 * 814 * Params: 815 * iconPos = icon position 816 * provider = a `GdkContentProvider` 817 * actions = a bitmask of the allowed drag actions 818 */ 819 public void setIconDragSource(GtkEntryIconPosition iconPos, ContentProvider provider, GdkDragAction actions) 820 { 821 gtk_entry_set_icon_drag_source(gtkEntry, iconPos, (provider is null) ? null : provider.getContentProviderStruct(), actions); 822 } 823 824 /** 825 * Sets the icon shown in the entry at the specified position 826 * from the current icon theme. 827 * 828 * If the icon isn’t known, a “broken image” icon will be 829 * displayed instead. 830 * 831 * If @icon is %NULL, no icon will be shown in the 832 * specified position. 833 * 834 * Params: 835 * iconPos = The position at which to set the icon 836 * icon = The icon to set 837 */ 838 public void setIconFromGicon(GtkEntryIconPosition iconPos, IconIF icon) 839 { 840 gtk_entry_set_icon_from_gicon(gtkEntry, iconPos, (icon is null) ? null : icon.getIconStruct()); 841 } 842 843 /** 844 * Sets the icon shown in the entry at the specified position 845 * from the current icon theme. 846 * 847 * If the icon name isn’t known, a “broken image” icon will be 848 * displayed instead. 849 * 850 * If @icon_name is %NULL, no icon will be shown in the 851 * specified position. 852 * 853 * Params: 854 * iconPos = The position at which to set the icon 855 * iconName = An icon name 856 */ 857 public void setIconFromIconName(GtkEntryIconPosition iconPos, string iconName) 858 { 859 gtk_entry_set_icon_from_icon_name(gtkEntry, iconPos, Str.toStringz(iconName)); 860 } 861 862 /** 863 * Sets the icon shown in the specified position using a `GdkPaintable`. 864 * 865 * If @paintable is %NULL, no icon will be shown in the specified position. 866 * 867 * Params: 868 * iconPos = Icon position 869 * paintable = A `GdkPaintable` 870 */ 871 public void setIconFromPaintable(GtkEntryIconPosition iconPos, PaintableIF paintable) 872 { 873 gtk_entry_set_icon_from_paintable(gtkEntry, iconPos, (paintable is null) ? null : paintable.getPaintableStruct()); 874 } 875 876 /** 877 * Sets the sensitivity for the specified icon. 878 * 879 * Params: 880 * iconPos = Icon position 881 * sensitive = Specifies whether the icon should appear 882 * sensitive or insensitive 883 */ 884 public void setIconSensitive(GtkEntryIconPosition iconPos, bool sensitive) 885 { 886 gtk_entry_set_icon_sensitive(gtkEntry, iconPos, sensitive); 887 } 888 889 /** 890 * Sets @tooltip as the contents of the tooltip for the icon at 891 * the specified position. 892 * 893 * @tooltip is assumed to be marked up with Pango Markup. 894 * 895 * Use %NULL for @tooltip to remove an existing tooltip. 896 * 897 * See also [method@Gtk.Widget.set_tooltip_markup] and 898 * [method@Gtk.Entry.set_icon_tooltip_text]. 899 * 900 * Params: 901 * iconPos = the icon position 902 * tooltip = the contents of the tooltip for the icon 903 */ 904 public void setIconTooltipMarkup(GtkEntryIconPosition iconPos, string tooltip) 905 { 906 gtk_entry_set_icon_tooltip_markup(gtkEntry, iconPos, Str.toStringz(tooltip)); 907 } 908 909 /** 910 * Sets @tooltip as the contents of the tooltip for the icon 911 * at the specified position. 912 * 913 * Use %NULL for @tooltip to remove an existing tooltip. 914 * 915 * See also [method@Gtk.Widget.set_tooltip_text] and 916 * [method@Gtk.Entry.set_icon_tooltip_markup]. 917 * 918 * If you unset the widget tooltip via 919 * [method@Gtk.Widget.set_tooltip_text] or 920 * [method@Gtk.Widget.set_tooltip_markup], this sets 921 * [property@Gtk.Widget:has-tooltip] to %FALSE, which suppresses 922 * icon tooltips too. You can resolve this by then calling 923 * [method@Gtk.Widget.set_has_tooltip] to set 924 * [property@Gtk.Widget:has-tooltip] back to %TRUE, or 925 * setting at least one non-empty tooltip on any icon 926 * achieves the same result. 927 * 928 * Params: 929 * iconPos = the icon position 930 * tooltip = the contents of the tooltip for the icon 931 */ 932 public void setIconTooltipText(GtkEntryIconPosition iconPos, string tooltip) 933 { 934 gtk_entry_set_icon_tooltip_text(gtkEntry, iconPos, Str.toStringz(tooltip)); 935 } 936 937 /** 938 * Set additional hints which allow input methods to 939 * fine-tune their behavior. 940 * 941 * Params: 942 * hints = the hints 943 */ 944 public void setInputHints(GtkInputHints hints) 945 { 946 gtk_entry_set_input_hints(gtkEntry, hints); 947 } 948 949 /** 950 * Sets the input purpose which can be used by input methods 951 * to adjust their behavior. 952 * 953 * Params: 954 * purpose = the purpose 955 */ 956 public void setInputPurpose(GtkInputPurpose purpose) 957 { 958 gtk_entry_set_input_purpose(gtkEntry, purpose); 959 } 960 961 /** 962 * Sets the character to use in place of the actual text 963 * in “password mode”. 964 * 965 * See [method@Gtk.Entry.set_visibility] for how to enable 966 * “password mode”. 967 * 968 * By default, GTK picks the best invisible char available in 969 * the current font. If you set the invisible char to 0, then 970 * the user will get no feedback at all; there will be no text 971 * on the screen as they type. 972 * 973 * Params: 974 * ch = a Unicode character 975 */ 976 public void setInvisibleChar(dchar ch) 977 { 978 gtk_entry_set_invisible_char(gtkEntry, ch); 979 } 980 981 /** 982 * Sets the maximum allowed length of the contents of the widget. 983 * 984 * If the current contents are longer than the given length, then 985 * they will be truncated to fit. The length is is in characters. 986 * 987 * This is equivalent to getting @entry's `GtkEntryBuffer` and 988 * calling [method@Gtk.EntryBuffer.set_max_length] on it. 989 * 990 * Params: 991 * max = the maximum length of the entry, or 0 for no maximum. 992 * (other than the maximum length of entries.) The value passed in will 993 * be clamped to the range 0-65536. 994 */ 995 public void setMaxLength(int max) 996 { 997 gtk_entry_set_max_length(gtkEntry, max); 998 } 999 1000 /** 1001 * Sets whether the text is overwritten when typing in the `GtkEntry`. 1002 * 1003 * Params: 1004 * overwrite = new value 1005 */ 1006 public void setOverwriteMode(bool overwrite) 1007 { 1008 gtk_entry_set_overwrite_mode(gtkEntry, overwrite); 1009 } 1010 1011 /** 1012 * Sets text to be displayed in @entry when it is empty. 1013 * 1014 * This can be used to give a visual hint of the expected 1015 * contents of the `GtkEntry`. 1016 * 1017 * Params: 1018 * text = a string to be displayed when @entry is empty and unfocused 1019 */ 1020 public void setPlaceholderText(string text) 1021 { 1022 gtk_entry_set_placeholder_text(gtkEntry, Str.toStringz(text)); 1023 } 1024 1025 /** 1026 * Causes the entry’s progress indicator to “fill in” the given 1027 * fraction of the bar. 1028 * 1029 * The fraction should be between 0.0 and 1.0, inclusive. 1030 * 1031 * Params: 1032 * fraction = fraction of the task that’s been completed 1033 */ 1034 public void setProgressFraction(double fraction) 1035 { 1036 gtk_entry_set_progress_fraction(gtkEntry, fraction); 1037 } 1038 1039 /** 1040 * Sets the fraction of total entry width to move the progress 1041 * bouncing block for each pulse. 1042 * 1043 * Use [method@Gtk.Entry.progress_pulse] to pulse 1044 * the progress. 1045 * 1046 * Params: 1047 * fraction = fraction between 0.0 and 1.0 1048 */ 1049 public void setProgressPulseStep(double fraction) 1050 { 1051 gtk_entry_set_progress_pulse_step(gtkEntry, fraction); 1052 } 1053 1054 /** 1055 * Sets a `PangoTabArray`. 1056 * 1057 * The tabstops in the array are applied to the entry text. 1058 * 1059 * Params: 1060 * tabs = a `PangoTabArray` 1061 */ 1062 public void setTabs(PgTabArray tabs) 1063 { 1064 gtk_entry_set_tabs(gtkEntry, (tabs is null) ? null : tabs.getPgTabArrayStruct()); 1065 } 1066 1067 /** 1068 * Sets whether the contents of the entry are visible or not. 1069 * 1070 * When visibility is set to %FALSE, characters are displayed 1071 * as the invisible char, and will also appear that way when 1072 * the text in the entry widget is copied elsewhere. 1073 * 1074 * By default, GTK picks the best invisible character available 1075 * in the current font, but it can be changed with 1076 * [method@Gtk.Entry.set_invisible_char]. 1077 * 1078 * Note that you probably want to set [property@Gtk.Entry:input-purpose] 1079 * to %GTK_INPUT_PURPOSE_PASSWORD or %GTK_INPUT_PURPOSE_PIN to 1080 * inform input methods about the purpose of this entry, 1081 * in addition to setting visibility to %FALSE. 1082 * 1083 * Params: 1084 * visible = %TRUE if the contents of the entry are displayed as plaintext 1085 */ 1086 public void setVisibility(bool visible) 1087 { 1088 gtk_entry_set_visibility(gtkEntry, visible); 1089 } 1090 1091 /** 1092 * Unsets the invisible char, so that the default invisible char 1093 * is used again. See [method@Gtk.Entry.set_invisible_char]. 1094 */ 1095 public void unsetInvisibleChar() 1096 { 1097 gtk_entry_unset_invisible_char(gtkEntry); 1098 } 1099 1100 /** 1101 * Emitted when the entry is activated. 1102 * 1103 * The keybindings for this signal are all forms of the Enter key. 1104 */ 1105 gulong addOnActivate(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1106 { 1107 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1108 } 1109 1110 /** 1111 * Emitted when an activatable icon is clicked. 1112 * 1113 * Params: 1114 * iconPos = The position of the clicked icon 1115 */ 1116 gulong addOnIconPress(void delegate(GtkEntryIconPosition, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1117 { 1118 return Signals.connect(this, "icon-press", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1119 } 1120 1121 /** 1122 * Emitted on the button release from a mouse click 1123 * over an activatable icon. 1124 * 1125 * Params: 1126 * iconPos = The position of the clicked icon 1127 */ 1128 gulong addOnIconRelease(void delegate(GtkEntryIconPosition, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1129 { 1130 return Signals.connect(this, "icon-release", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1131 } 1132 }